package com.coisshi.base.module.oss.service;

import com.coisshi.base.common.exception.BizException;
import com.coisshi.base.framework.config.properties.CloudStorageProperties;
import com.coisshi.base.module.oss.service.impl.AliyunOssServiceImpl;
import com.coisshi.base.module.oss.service.impl.TencentCosServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class CloudStorageFactory {
    private final AliyunOssServiceImpl aliyunOssService;
    private final TencentCosServiceImpl tencentCosService;
    private final CloudStorageProperties properties;

    public CloudStorageService getService() {
        return switch (properties.getType()) {
            case "aliyun" -> aliyunOssService;
            case "tencent" -> tencentCosService;
            default -> throw new BizException("不支持的云存储类型: " + properties.getType());
        };
    }
} 